#pragma once
#include "common.h"

class ExtException : private std::exception {
public:
	ExtException(E_STRING fileName, uint32_t line, E_STRING fmt, ...);
	const E_STRING& GetMessage() const;
	const E_STRING& GetFileName() const;
	uint32_t 		GetLine() const;
	uint32_t		GetHours() const;
	uint32_t		GetMinutes() const;
	uint32_t		GetSeconds() const;
	uint32_t		GetMSeconds() const;

private:
	ExtException(const ExtException&);
	ExtException& operator=(const ExtException&);

	struct Time {
		uint32_t Hour;
		uint32_t Minute;
		uint32_t Second;
		uint32_t MSecond;
	};

	E_STRING m_fileName;
	uint32_t m_line;
	E_STRING m_msg;
	Time	 m_time;
};

inline ExtException::ExtException(E_STRING filename, uint32_t line, E_STRING fmt, ...) {
	char buf[1024];
    va_list args;
    va_start(args, in_format);
    vsnprintf(buf, 1024, fmt.c_str(), args);
    m_msg = buf;
    m_fileName = filename;
    m_line = line;
}

inline const E_STRING& ExtException::GetMessage() const {
	return m_msg;
}

inline const E_STRING& ExtException::GetFileName() const {
	return m_fileName;
}

inline uint32_t ExtException::GetLine() const {
	return m_line;

}

inline uint32_t ExtException::GetHours() const {
	return m_time.Hour;
}

inline uint32_t ExtException::GetMinutes() const {
	return m_time.Minute;
}

inline uint32_t ExtException::GetSeconds() const {
	return m_time.Second;
}

inline uint32_t ExtException::GetMSeconds() const {
	return m_time.MSecond;
}

#define EXT_EXCEPTION(fmt, ...) ExtException(_E_FILE_, __LINE__, fmt, __VA_ARGS__) 